<?php
$version = Zend_Registry::get('version');  
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/qtip2/jquery.qtip.js');
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/table-sorter/jquery.dataTables.js');


if(!empty($group_datas['meta_keywords'])) { $this->headMeta()->setName('keywords',$this->group_datas['meta_keywords']);}
if(!empty($this->group_datas['meta_desc'])) { $this->headMeta()->setName('description',$this->group_datas['meta_desc']); }
if(!empty($this->group_datas['gallery_name'])) { $this->headTitle()->headTitle($this->group_datas['gallery_name'],'SET')->setSeparator(' - ')->headTitle($this->group_datas['meta_title']); }
$this->headTitle($this->translator->translator('gallery_simple_search_title'));


$global_conf = Zend_Registry::get('global_conf');
$currency = new Zend_Currency($global_conf['default_locale']);

echo $this->headLink()->setStylesheet($this->baseUrl().'/js/jquery/pirobox/css_pirobox/demo5/style.css'); 
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/pirobox/pirobox.js');
?>
		
<script type="text/javascript">
	$(document).ready(function (){
	
	/****************************Sorting Table Start*********************/
	var oTable = $("#sortTable").dataTable({
				"bPaginate": true,
				"aLengthMenu" : [ 5, 10, 20, 50, 100 ],
				"sPaginationType": "full_numbers",
				"bLengthChange": true,
				"bSearchable": false,
				"bFilter": false,
				"bSort": false,
				"bInfo": false,
				"bAutoWidth": true,
				"bProcessing": false,
				"bSortClasses": true,
				"bStateSave": false,
				"bServerSide": false,				
				"aoColumnDefs": [ 
						{ "bSortable": false, "bSortClasses": false,  "aTargets": [ 0 ] }
					],
				"oLanguage" : { "sSearch": "<?php echo $this->translator->translator('jquery_filter'); ?>" }
			}); 	
	/****************************Sorting Table End*********************/
	
	$('.pirobox').piroBox({
			my_speed: 300, //animation speed
			bg_alpha: 0.7, //background opacity
			slideShow : false, // true == slideshow on, false == slideshow off
			slideSpeed : 4, //slideshow duration in seconds(3 to 6 Recommended)
			close_all : '.piro_close,.piro_overlay'// add class .piro_overlay(with comma)if you want overlay click close piroBox

	});
	
	$('img[title]').qtip({			
				position: { my: 'bottom left', at: 'top center' },
				show: {  target: false, event: 'mouseover', effect: function(offset) { /*$(this).slideDown(200);*/ $(this).show(300); } },
				hide: {  event: 'mouseout' , effect: function(offset) { /*$(this).slideUp(200);*/ $(this).hide(300); } },
				style: { classes: 'ui-tooltip-frontend' }
			});
	
	
});
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 
</script>
<style type="text/css">
	/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
	 * DataTables features
	 */
	 
	 .no_picture_found
	 {
	 	color:#999999;
		font-size:13px;
		font-style:italic;
	 }
	
	.dataTables_wrapper {
		position: relative;
		/*min-height: 302px;*/
		clear: both;
		_height: 302px;
		zoom: 1; /* Feeling sorry for IE */
	}
	
	.dataTables_processing {
		position: absolute;
		top: 50%;
		left: 50%;
		width: 250px;
		height: 30px;
		margin-left: -125px;
		margin-top: -15px;
		padding: 14px 0 2px 0;
		border: 1px solid #ddd;
		text-align: center;
		color: #999;
		font-size: 14px;
		background-color: white;
	}
	
	.dataTables_length {
		width: 20%;
		float: right;
	}
	
	.dataTables_filter {
		width: 100%;
		/*float: left;*/
		text-align: left;
		padding-bottom:5px;
	}
	
	.dataTables_info {
		width: 60%;
		float: left;
	}
	
	.dataTables_paginate {
		width: 44px;
		* width: 50px;
		float: right;
		text-align: center;
	}
	
	/* Pagination nested */
	.paginate_disabled_previous, .paginate_enabled_previous, .paginate_disabled_next, .paginate_enabled_next {
		height: 19px;
		width: 19px;
		margin-left: 3px;
		float: left;
	}
	
	.paginate_disabled_previous {
		background-image: url('data/adminImages/commonImages/table-sorter/back_disabled.jpg');
	}
	
	.paginate_enabled_previous {
		background-image: url('data/adminImages/commonImages/table-sorter/back_enabled.jpg');
	}
	
	.paginate_disabled_next {
		background-image: url('data/adminImages/commonImages/table-sorter/forward_disabled.jpg');
	}
	
	.paginate_enabled_next {
		background-image: url('data/adminImages/commonImages/table-sorter/forward_enabled.jpg');
	}
	
	.paging_full_numbers {
		width: 100%;
		height: 22px;
		line-height: 22px;
	}
	
	.paging_full_numbers span.paginate_button,
		.paging_full_numbers span.paginate_active {
		border: 1px solid #aaa;
		-webkit-border-radius: 5px;
		-moz-border-radius: 5px;
		padding: 2px 5px;
		margin: 0 3px;
		cursor: pointer;
		*cursor: hand;
	}
	
	.paging_full_numbers span.paginate_button {
		background-color: #ddd;
	}
	
	.paging_full_numbers span.paginate_button:hover {
		background-color: #ccc;
	}
	
	.paging_full_numbers span.paginate_active {
		background-color: #99B3FF;
	}
</style>

<div class="mod mod-gallery">
    <div class="search-icon">
        <h1><?php echo $this->translator->translator('gallery_simple_search_title');?></h1>
    </div>

	<div class="clear">&nbsp;</div>

    <div class="mod-container simple-container">
        <form name="search_gallery_image" method="post" action="<?php echo $this->url( array('module' => 'Gallery','controller' => 'Gallerysearch', 'action'     => 'simplesearch' ), 'Gallery-Search',    true) ?>">
            <?php echo $this->searchForm->search_text;?>
            <input type="submit" value="Submit" class=""/>
            <span id="search_text_err"></span>
        </form>
    </div>
    <?php
    if($this->result)
    {
    ?>
    <div class="result-title"><?php echo $this->translator->translator('gallery_search_list_title'); ?>: <?php echo $this->translator->translator('gallery_search_list_found_title', count($this->result)); ?></div>
    
    <div class="gallery-container">
            <?php			
                $i =1 ;
                $col_num =  4;	
                if(null !== $this->result && count($this->result) > 0):
                foreach ($this->result as $entry=>$value):
                
                $group_datas = $this->viewHelper->_getGallery_info($value['group_id']);
                    
                $link = $this->url( array('module' => 'Gallery','controller' =>'Gallerysearch','action' => 'searchdetails','id' => $value['id']), 'Search-Details/:id',    true);
                $product_thumb_val_arr = explode(',',$value['product_thumb']);
                $product_file_val_arr = explode(',',$value['product_file']);
                if($value['featured'] == '1')
                {
                    $style = 'style="background: #FF0000;"';
                }
                else
                {
                    $style = "";
                }				
                if($this->escape($value['product_thumb_primary']))
                { 
                    $thumb_image = 'data/frontImages/gallery/product_thumb/'.$this->escape($value['product_thumb_primary']); 
                }
                else
                { 
                    if($this->escape($value['product_thumb']))
                    {
                        
                        $thumb_image = 'data/frontImages/gallery/product_thumb/'.$this->escape($product_thumb_val_arr[0]); 
                    }
                    else
                    {
                        if($this->escape($value['product_file_primary']))
                        {
                            $thumb_image = 'data/frontImages/gallery/product_image/'.$this->escape($value['product_file_primary']); 
                        }
                        else
                        {
                            
                            $thumb_image = 'data/frontImages/gallery/product_image/'.$this->escape($product_file_val_arr[0]); 
                        }
                    }		
                }
                 
                if($this->escape($value['product_file_primary']))
                {
                    $light_box_image = 'data/frontImages/gallery/product_image/'.$this->escape($value['product_file_primary']); 
                }
                else
                {
                    $product_file_val_arr = explode(',',$value['product_file']);
                    $light_box_image = 'data/frontImages/gallery/product_image/'.$this->escape($product_file_val_arr[0]); 
                }
                $img_title_desc = '<b>'.$this->translator->translator('gallery_common_name').'</b> '.$this->escape($value['product_name']);	
                $img_title_desc .=	($this->escape($value['product_code'])) ? '<br /><b>'.$this->translator->translator('gallery_common_code').'</b> '.$this->escape($value['product_code']) : '';
                $img_title_desc .=	($this->escape($value['product_price'])) ? '<br /><b>'.$this->translator->translator('gallery_common_price').'</b> '.$this->escape($value['product_price']).'&nbsp;'.$currency->getSymbol() : '';
                $img_title_desc .=	($this->escape($value['product_desc'])) ? '<br /><b>'.$this->translator->translator('gallery_common_desc').'</b> '.strip_tags($this->escape($value['product_desc'])) : '';
            ?>
            
            <div class="image-box">
                <div class="gallery-thumb">            	
                    <a <?php if($group_datas['light_box_on'] == '1'){ ?>class="preview" link="<?php echo $thumb_image; ?>" width="300px" href="<?php echo $link; ?>" title="<?php echo $this->escape($value['product_title']); ?>" <?php }else{ ?> href="<?php echo $link; ?>" <?php } ?> ><img src="<?php echo $thumb_image; ?>" width="120" border="0" class="thumb-img" /></a>
                </div>
                <div class="info-container product-info product-label">
                    <span><?php echo $this->translator->translator('gallery_common_name'); ?></span> <a href="<?php echo $link; ?>"><?php echo $this->escape($value['product_name']); ?></a><br />
                    <span><?php echo $this->translator->translator('gallery_common_image_no'); ?></span> <?php echo count($product_file_val_arr); ?><br />
                    <?php if($value['product_code']){ ?>
                    <span><?php echo $this->translator->translator('gallery_common_code'); ?></span> <?php echo $this->escape($value['product_code']); ?><br />
                    <?php } ?>
                    <span><?php echo $this->translator->translator('gallery_common_price'); ?></span> <?php echo $this->escape($value['product_price']).'&nbsp;'.$currency->getSymbol(); ?><br />
                    <span><?php echo $this->translator->translator('gallery_common_cpyright'); ?></span> <?php echo $this->escape($global_conf['site_name']); ?><br />
                </div>
                
                <div class="icon">
                    <div class="icon-bg"><span class="big-view"><a href="<?php echo $light_box_image; ?>" class="pirobox" title="<?php echo $this->escape($value['product_name']); ?>"></a></span></div>
                    <div class="icon-bg"><span class="img-details"><a href="<?php echo $link; ?>" title="Image Details"></a></span></div>
                </div>
            </div>
            
        <?php	
            $i++;
            endforeach;	
            else:
                echo '<div class="result-title">'.$this->translator->translator('gallery_no_picture_found_error').'</div>';
            endif;		
        ?>
    </div>
    <?php
    }
    ?>
</div>